package com.shouxin.log.log4j;

import android.os.Environment;

import org.apache.log4j.Level;

import java.io.File;

/**
 * <p>用于Log输出到外存储，方便后续定位。</p>
 * Created by Jiangqg on 2016/2/28.
 */
public final class LogUtils {

	private static final String LOCAL_PATH = Environment.getExternalStorageDirectory() + File.separator + "School-Attendance" + File.separator;

	private static final String LOCAL_FILE = "DebugLog.log";

	public static void init() {
		LogConfigurator logConfigurator = new LogConfigurator();
		logConfigurator.setFileName(LOCAL_PATH + LOCAL_FILE);
		logConfigurator.setFilePattern("%d - [%p::%c] - %m%n");
		// 100 * 1024
		logConfigurator.setMaxFileSize(102400L);
		// 10个文件循环写
		logConfigurator.setMaxBackupSize(5);
		logConfigurator.setImmediateFlush(true);
		// Set the root log level
		logConfigurator.setRootLevel(Level.DEBUG);
		logConfigurator.configure();
	}

}
